/**************************************************************************
 *         Copyright(c) 2007 by Sunplus mMedia  Technology Co., Ltd.       *
 *                                                                         *
 *  This software is copyrighted by and is the property of Sunplus mMedia  *
 *  Technology Co., Ltd. All rights are reserved by Sunplus mMedia Techno- *
 *  logy Co., Ltd. This software may only be used in accordance with the   *
 *  corresponding license agreement. Any unauthorized use, duplication,    *
 *  distribution, or disclosure of this software is expressly forbidden.   *
 *                                                                         *
 *  This Copyright notice "M U S T" not be removed or modified without     *
 *  prior written consent of Sunplus mMedia Technology  Co., Ltd.          *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd. reserves the right to modify this  *
 *  software without notice.                                               *
 *                                                                         *
 *  Sunplus mMedia Technology Co., Ltd.                                    *
 *  19-1, Innovation First Road, Science-Based Industrial Park,            *
 *  Hsin-Chu, Taiwan, R.O.C.                                               *
 *                                                                         *
 **************************************************************************/

#ifndef __APP_UI_POWER_H__
#define __APP_UI_POWER_H__

#define _PwrCtrlEn	0x00

//=============================================================================
//Header file
//=============================================================================
#include "gpio.h"
#include "app_battery.h"
#include "exifhdr.h"

//=============================================================================
//Symbol
//=============================================================================

#define FUNC_CLEAR

#if 0
/****panel related define****/
#define TV_PLUG_IN		0x00
#define TV_PLUG_OUT		0x04
#endif

/****USB related define****/
#define USB_PLUG_IN		0x40
#define USB_PLUG_OUT	0x00//sp1kCon_PlugGet()
#define USB_DBG bUsbPwr

/****Sd protection****/
#define SD_PROTECT		0x01
#define SD_UNPROTECT	0x00

/****Auto Power off****/
#define AUTO_POWEROFF_ENABLE	0x01
#define AUTO_POWEROFF_DISABLE	0x00

/****high lum white LED****/
/*when < EV7 LED turn on*/
#define WHITE_LED

//------------------------------------------------------------------------------
//Constant
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//Data type
//------------------------------------------------------------------------------
#if 0
typedef enum powerBatLv {
	POWER_BAT_FULL = 0x00,
	POWER_BAT_HALF = 0x01,
	POWER_BAT_LOW = 0x02,
	POWER_BAT_EMPTY = 0x03,
	POWER_BAT_BELOWEMPTY = 0x04,
	POWER_BAT_TOTAL = 0x05,
} powerBatLv_t;
#endif

typedef enum panelStatus {
	PANEL_STATUS_LCD = 0x00,
	PANEL_STATUS_NTSC = 0x01,
	PANEL_STATUS_PAL = 0x02,
	PANEL_STATUS_RESET = 0xFF,
	PANEL_STATUS_TOTAL = 0x04,
} panelStatus_t;

typedef enum pwrCtrlMode {
	MODE_DEFAULT 	= 0x00,
	MODE_PREVIEW	= 0x01,
	MODE_STILLCap 	= 0x02,
	MODE_STILLPB 	= 0x03,
	MODE_VIDEOREC = 0x04,
	MODE_VIDEOPB 	= 0x05,
	MODE_AUDIOREC	= 0x06,
	MODE_AUDIOPB 	= 0x07,
	MODE_USBPCCAM= 0x08,
	MODE_USBMSDC	= 0x09,
	MODE_USBSIDC	= 0x0A,
} pwrCtrlMode_t;

typedef struct appPwrCtrlPara_s {
	UINT8 cpuclk;
	UINT8 dramclk;
	UINT8 reg2013;
	UINT8 reg2014;
	UINT8 reg2015;
} appPwrCtrlPara_t;

//------------------------------------------------------------------------------
//Function Prototype
//------------------------------------------------------------------------------
extern UINT8 xdata storageReadyflag;
void appPowerOffProc(void);
void appAutoOffTimeReload(void);
void appUDFSave(void);
UINT8 appUDFLoad(void);
UINT8 appUDFCheckSum(void);
void appBatLvGet(powerBatLv_t* batlv);
void appTVOutDetect(void);//jintao.liu 2008-3-12 test
void appPanelStatusGet(panelStatus_t* panelMode);
void appPanelStatusSet(panelStatus_t panelMode);
void appDispSet(void);
void appSDPlugAction(void);
void appUSBOutDetect(void);
void appStorageMount (UINT8 type);
UINT8 appAutoOffTimeSet(void);
UINT8 appSDPlugStatusGet(void);
UINT8 appPowerCtrl(void) ;
UINT8 appModePowerCtrl(UINT8 mode) ;
void appPwrOffBGShow(void);
UINT8 appPanelTypeGet(void);
UINT8 appSDProtectStatusGet(void);
void appAutoOffEn(UINT8 En);
void appPowerShutDown(void);
void appSdPowerRecycle(void);
UINT8 appBattStsHandle(void);
#ifdef WHITE_LED
void appWhiteLedCtrl(void);
#endif
UINT8 appBGImgDec(UINT32 resId, struct Exif_Decompress_Parameter* pImgAttr, UINT32 srcAddr, UINT32 dstAddr, UINT8 bWait);

#endif /*__APP_UI_POWER_H__*/

